package org.shop.service.impl;

import org.shop.dao.UserDao;
import org.shop.dao.impl.UserDaoImpl;
import org.shop.entity.User;
import org.shop.service.UserService;
import org.shop.util.MD5Util;

/**
 * UserService接口的实现类 - 接口的其中的一种实现（方案）
 * 
 * @author Administrator
 *
 */
public class UserServiceImpl implements UserService {
	// 实例化UserDao对象
	UserDao userDao = new UserDaoImpl() ;

	@Override
	public User login(String username, String password) {
		// 根据用户名称查询用户信息
		User user = userDao.selectUser(username);

		// 判断密码是否匹配
		if (user != null && MD5Util.equals(password, user.getPassword())) {
			return user ;
		}

		return null ;
	}

}
